package cn.wolfcode.luowowo.serach.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;


@Setter
@Getter
public class SearchQueryObject extends QueryObject {

    //条件类型
    public static final int CONDITION_TYPE_ABROAD = 0;  //国外
    public static final int CONDITION_TYPE_UN_ABROAD = 1; //国内
    public static final int CONDITION_TYPE_THEME = 2; //主题

    private String orderBy = "viewnum";  //排序

    private Integer type = -1;   //条件类别 : 省份id  国家id 主题id    // 关键字搜索时候用于区分不同类别
    private Integer typeValue = -1; //条件值

    private Long destId = -1L;   //目的地id


    public Pageable getPageable() {
        return PageRequest.of(super.getCurrentPage() - 1, super.getPageSize(), Sort.Direction.DESC, orderBy);
    }

    public Pageable getPageableWithoutSort() {
        return PageRequest.of(super.getCurrentPage() - 1, super.getPageSize());
    }

}
